﻿using B.S.Warehouse.ErrorCord;
using B.S.Warehouse.Write.Api.Application.Command.WarehouseManagementCommand;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Warehouse.Write.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class WarehouseManagementController : ControllerBase
    {
        private readonly IMediator mediator;

        public WarehouseManagementController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 新增仓库
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public async Task<ApiResult<object>> AddWareHouse(AddWareHouseCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 新增仓库库位
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public async Task<ApiResult<object>> AddStorageArea(AddStorageAreaCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 新增仓库仓位
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public async Task<ApiResult<object>> AddStorageLocation(AddStorageLocationCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 删除仓库仓位 
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public async Task<ApiResult<object>> DelStorageLocation(DelStorageLocationCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 删除仓库库位
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public async Task<ApiResult<object>> DelStorageArea(DelStorageAreaCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 删除仓库
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public async Task<ApiResult<object>> DelWareHouse(DelWareHouseCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 修改仓库
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public async Task<ApiResult<object>> UpdateWareHouse(UpdateWareHouseCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 修改库位
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public async Task<ApiResult<object>> UpdateStorageArea(UpdateStorageAreaCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 修改仓位
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public async Task<ApiResult<object>> UpdateStorageLocation(UpdateStorageLocationCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
